package com.usian.admin.controller;

import com.usian.admin.mapper.AdSensitiveMapper;
import com.usian.admin.service.AdSensitiveService;
import com.usian.apis.admin.AdSensitiveControllerApi;
import com.usian.model.admin.dtos.SensitiveDto;
import com.usian.model.admin.pojos.AdSensitive;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理",tags = "sensitive",description = "敏感词管理的接口")
public class AdSensitiveController implements AdSensitiveControllerApi {

    @Autowired
    private AdSensitiveService adSensitiveService;



    @Override
    @PostMapping("/list")
    @ApiOperation(value = "查询",notes = "分页模糊查询")
    @ApiImplicitParam(name = "dto",type = "SensitiveDto",value = "查询条件")
    public ResponseResult list(@RequestBody SensitiveDto dto) {
        return adSensitiveService.list(dto);
    }

    @Override
    @PostMapping("/save")
    @ApiOperation(value = "添加",notes = "新增敏感词")
    @ApiImplicitParam(name = "adSensitive",type = "AdSensitive",value = "敏感词对象")
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    @Override
    @PostMapping("/update")
    @ApiOperation(value = "修改",notes = "修改敏感词")
    @ApiImplicitParam(name = "adSensitive",type = "AdSensitive",value = "敏感词对象")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    @Override
    @RequestMapping("/del/{id}")
    @ApiOperation(value = "删除",notes = "删除敏感词")
    @ApiImplicitParam(name = "id",type = "Integer",value = "敏感词主键")
    public ResponseResult deleteById(@PathVariable Integer id) {
        return adSensitiveService.deleteById(id);
    }



}
